home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
clipper
/
comm_io.zip
/
COMM_IO.ASM
next >
Wrap
Assembly Source File
|
1986-12-09
|
22KB
|
612 lines
page,132
;-------------------------------------------------------------------------------
; ---- COMM_IO.ASM ----
; To use it just MODE your COM1: to whatever speed you like, I've only tested
; it to 9600 baud it does'nt use DOS calls so its pretty fast I dont know
; how it will effect non IBM hardware, works just fine on PC'S Limited 286-8.
; It may not be fully debugged, I have'nt tested the XON or XOFF functions
; Simple communications work fine, It ignores the modem control line so to use
; it you must provide software handshaking for a terminal that does'nt have a
; buffer.
; The recieving buffer is 512 bytes so as long as you dont let it fillup you
; wont loose any characters, of coarse you could make it as larger if necessary.
;
;
; Filename: COMM_IO
; Program.: Clipper Communication for Com1:
; Authors.: Curt Klinsing,Modifed by Patrick Jonte
; Date....: April 20, 1986
;
; Function: A set of Clipper W85 callable functions to support
; interrupt driven character I/O on the IBM PC. Input
; is buffered, output is polled.
;
;
;
; 1- OUTP_CHAR {call} outputs a character string up to first null encountered.
; (Note- all clipper strings are terminated by a ascii null or hex 00)
; Example:
; PUTCHARS='a character string '
; CALL OUTP_CHAR WITH PUTCHARS
;
; 2- INP_CHAR(.T.or.F.) {function} returns a character string of the characters
; available in the input buffer (maximum of 512 characters)
; and gives the option of deleting characters read from input buffer .T. or
; .F. leaving it untouched which allows easy monitoring for a special
; character(s)
; Example:
; RECV_STR=INP_CHAR(.T.) & reads buffer and kills characters read
; from buffer
;
; 3- INP_CNT() {function} returns numeric indicating the number of characters
; that the input buffer is holding (Maximum of 512).
; Example:
; NUMCHAR=INP_CNT()
;
; 4- SET_XOFF {CALL} enables or disables xoff control .
; Example:
; SOFF=.T. && if you want to turn xoff feature on
; SOFF=.F. && to turn it off
; CALL SET_XOFF WITH SOFF
;
; 5- GET_XOFF(),RECV_XOFF(),SENT_XOFF() {FUNCTION} return logical value
; indicating state of control flags
; Example:
; GFLAG=GET_XOFF()
;
; 6- INIT_COMM,UNINIT_COM,INP_FLUSH {CALL} dont pass or return parameters
; Example:
; CALL INIT_COMM
; CALL INP_FLUSH
;---------------------------------------------------------------------------
;
name COMM_IO
public init_comm ;initialize the comm port,
public uninit_com ;remove initialization,
public set_xoff ;enable/disable XON/XOFF,
public get_xoff ;read XON/XOFF state,
public rcvd_xoff ;returns true if XOFF rcvd,
public sent_xoff ;true if XOFF sent,
public inp_cnt ;returns count of rcv chars,
public inp_char ;get char string from buffer,
public inp_flush ;flush input buffer,
public outp_char ;output a character string,
;
extrn _retc:far ; return character string
extrn _retds:far ; return date type from date string "YYYYMMDD"
extrn _retl:far ; return logical true or false
extrn _retni:far ; return word as numeric
extrn _retnl:far ; return double word as numeric
extrn _retnd:far ; return floating point as numeric
;
extrn _parc:far ; pass character string
extrn _parni:far ; pass integer numeric
extrn _parnl:far ; pass integer long numeric
extrn _parnd:far ; pass double numeric
extrn _parl:far ; pass logical integer
extrn _pards:far ; pass date string "yyyymmdd"
;
extrn _parinfo:far ; UNDEF 0
; CHARACTER 1
; NUMERIC 2
; LOGICAL 4
; DATE 8
; ALIAS 16
; MPTR 32
; MEMO 65
; WORD 128
_prog segment byte public 'code'
assume cs:_prog
;
;
FALSE EQU 0
TRUE EQU NOT FALSE
BASE EQU 03F8H ;BASE FOR SERIAL BOARD COMM1
LCR EQU BASE+3 ; Line control register
IER EQU BASE+1 ; Interrup Enable Register
MCR EQU BASE+4 ; modem control register
EnblDRdy EQU 01H ; enable 'data-ready' interrupt bit
IntCtlr EQU 21H ; OCW 1 FOR 8259 CONTROLLER
EnblIRQ4 EQU 0EFH ; Enable COMMUNICATIONS (IRQ4) COMM1
DATAPORT EQU BASE ; transmit/receive data port
MaskIRQ4 EQU 10H ; BIT TO DISABLE COMM INTERRUPT (IRQ4)
MDMSTA EQU BASE+5 ; line status register
MDMMSR EQU BASE+6 ; modem status register
MDMBAD EQU BASE ; lsb baud resgister
MDMBD1 EQU BASE+1 ; msb baud rate register
MDMCD EQU 80H ; mask for carrier dectect
SETBAU EQU 80H ; code for Divisor Latch Access Bit
MDMTBE EQU 20H ; 8250 tbe flag
MDMBRK EQU 40H ; command code for 8250 break
LINMOD EQU 03H ; line mode=8 bit, no parity
MDMMOD EQU 0BH ; modem mode = DTR and RTS HIGH
STOP2 EQU 04H ; BIT FOR TWO STOP BITS IF BAUD<300
RS8259 EQU 20H ; OCW 3 FOR 8259
RSTINT EQU 64H ; SPECIFIC EOI FOR COMM INTERRUPT
XOFF EQU 13H ; XOFF character
XON EQU 11H ; XON character
;
; MISCELLANEOUS EQUATES
;
CR EQU 13
LF EQU 10
DosCall EQU 33 ;INTERRUPT NUMBER FOR DOS CALL
CNSTAT EQU 11 ;FUNCTION NUMBER FOR CONSOLE STATUS
CNIN EQU 1 ;FUNCTION NUMBER FOR CONSOLE INPUT
BUFSIZ EQU 512 ;Max NUMBER OF CHARS
SetIntVect EQU 25H ;SET INTERRUPT VECTOR FUNCTION NUMBER
;
; DUMP BUFFER, COUNT AND POINTER.
;
CIRC_BUF DB BUFSIZ DUP(?) ;ALLOW 512 MAXIMUM BUFFERED CHARACTERS
BUF_TOP EQU $ - 1 ;KEEP TRACK OF THE TOP OF THE BUFFER
OUT_BUF DB BUFSIZ DUP(?) ;TEMP BUFF AREA FOR CALLING PROCEDURE
CIRC_TOP DW BUF_TOP ;
CIRC_IN DW OFFSET CIRC_BUF ;POINTER TO LAST CHAR. PLACED IN BUFFER
CIRC_CUR DW OFFSET CIRC_BUF ;POINTER TO NEXT CHAR. TO BE RETRIEVED FROM
; BUFFER
CIRC_CT DW 0 ;COUNT OF CHARACTERS USED IN BUFFER
SNT_XOFF DB FALSE ;FLAG TO CHECK IF AN XOFF HAS BEEN SEND
GOT_XOFF DB FALSE ;FLAG TO CHECK IF AN XOFF HAS BEEN RECEIVED
SEE_XOFF DB FALSE ;FLAG TO SEE IF WE ARE INTERESTED IN XON/XOFF
CIRC_OUT DW 0 ;NUMBER OF CHARACTERS RETURNED TO CLIPPER
INTR_CUR DW 0 ;BUFFER FOR INP_CHAR
INTR_CT DW 0 ;BUFFER FOR INP_CHAR
KILLSTR DB 0 ;FLAG PASSED TO KILL BUFFER UPON READING
;
;
;
;set_xoff(flag) Enable (flag = 1 ) or disable
;int flag; (flag = 0 ) XON/ XOFF protocol
; for the character input stream.
;If enabled, an XOFF will be sent when the buffer
;reaches 3/4 full. NOTE: an XON will not be sent auto-
;matically. Your program must do it when it sees
;the rcvd_xoff() flag, and ready for more chars.
;
set_xoff proc far
push bp
mov bp,sp
PUSH DS ;SAVE DATA SEGMENT
lds si,dword ptr [bp+6] ; get calling varible addr off stack
xor ax,ax
lodsb ; load al with calling variable
push cs
pop ds ; move code seg addr to data seg reg.
cmp al,0 ; check for logic 0
jnz to_on ; if not 0 set it true=-1
mov see_xoff,FALSE
jmp done1
to_on: mov see_xoff,TRUE
done1: pop ds
pop bp
ret
set_xoff endp
;
;flag= get_xoff() Returns the current setting
; of the XON/ XOFF flag set
;by set_xoff(), ab